/*
*    Author : heiden deng(dengjianquan@beyondcent.com)
*    2017/08/03
*    version 0.0.9
*    基于权重的round robin 负载均衡处理类声明
*/

#ifndef HTSC_GRPC_WEIGHT_ROUNDROBIN_H
#define HTSC_GRPC_WEIGHT_ROUNDROBIN_H

#include "htsc_loadbalance.h"
#include<map>
#include<vector>

#ifdef __cplusplus
extern "C" {
#endif

class WeightRoundRobinLB :
	public htsc_grpc_loadbalance
{
public:
	WeightRoundRobinLB();
	~WeightRoundRobinLB();
	void setProviders(std::map<std::string, std::vector<provider_t*> > *_providers);
	void resetCursor(const char* sn);
	provider_t* chooseProvider(const char* sn, int step = 0);
private:
	std::map<std::string, std::vector<provider_t*> > *providers;
	//某服务的选择的provider位置
	std::map<std::string, int> cursors;
};

#ifdef __cplusplus
}
#endif

#endif // !HTSC_GRPC_WEIGHT_ROUNDROBIN_H



